import 'dart:convert';

class Record {
  final String? id;
  final String? content;
  final String? cover;
  final String? userId;
  final String? categoryId;
  final String? categoryName;
  final String? categoryPid;
  final String? categoryPName;
  final String? otherUserId;
  final String? album;
  final String? albumName;
  final List<String>? imgsUrl;
  final int? count;
  final List<String>? tagList;
  final String? viewCount;
  final String? agreeCount;
  final String? collectionCount;
  final String? commentCount;
  final String? time;
  final String? avatar;
  final String? username;
  Record({
    this.id,
    this.content,
    this.cover,
    this.userId,
    this.categoryId,
    this.categoryName,
    this.categoryPid,
    this.categoryPName,
    this.otherUserId,
    this.album,
    this.albumName,
    this.imgsUrl,
    this.count,
    this.tagList,
    this.viewCount,
    this.agreeCount,
    this.collectionCount,
    this.commentCount,
    this.time,
    this.avatar,
    this.username
  });

  factory Record.fromJson(Map<String, dynamic> json) {
    return Record(
      id: json['id'],
      content: json['content'],
      cover: json['cover'],
      userId: json['userId'],
      categoryId: json['categoryId'],
      categoryName: json['categoryName'],
      categoryPid: json['categoryPid'],
      categoryPName: json['categoryPName'],
      otherUserId: json['otherUserId'],
      album: json['album'],
      albumName: json['albumName'],
      imgsUrl: json['imgsUrl'] == null ? null : (json['imgsUrl']! as List).map((item) => item as String).toList(),
      count: json['count'],
      tagList: json['tagList'] == null ? null : (json['tagList'] as List).map((item) => item as String).toList(),
      viewCount: json['viewCount'],
      agreeCount: json['agreeCount'],
      collectionCount: json['collectionCount'],
      commentCount: json['commentCount'],
      time: json['time'],
      avatar: json['avatar'],
      username: json['username']
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['content'] = content;
    data['cover'] = cover;
    data['userId'] = userId;
    data['categoryId'] = categoryId;
    data['categoryName'] = categoryName;
    data['categoryPid'] = categoryPid;
    data['categoryPName'] = categoryPName;
    data['otherUserId'] = otherUserId;
    data['album'] = album;
    data['albumName'] = albumName;
    data['imgsUrl'] = imgsUrl;
    data['count'] = count;
    data['tagList'] = tagList;
    data['viewCount'] = viewCount;
    data['agreeCount'] = agreeCount;
    data['collectionCount'] = collectionCount;
    data['commentCount'] = commentCount;
    data['time'] = time;
    return data;
  }
}

class Records {
  late final List<Record>? records;
  bool? hasNext = true;
  Records({required this.records});

  factory Records.fromJson(List< dynamic> json) {
    return Records(
      records: (json.map((item) => Record.fromJson(item)).toList()));
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['records'] = records!.map((item) => item.toJson()).toList();
    return data;
  }
}